package org.come.npc;

import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.FrameMessageChangeJpanel;
import org.come.action.NpcMenuAction;
import org.come.bean.PrivateData;
import org.come.bean.Skill;
import org.come.until.AnalysisString;
import org.come.until.SendRoleAndRolesummingUntil;
import org.come.until.UserMessUntil;

/**
 * 学习法门
 * @author Administrator
 *
 */
public class SkillLearn2 implements NpcMenuAction{

	@Override
	public void menuControl(String type) {
		if (type==null|| "".equals(type)) {return;}
		Skill skill=UserMessUntil.getskill1(type);
		if (skill==null) {return;}
		PrivateData data=RoleData.getRoleData().getPrivateData();
		String[] vs=data.getSkill("F");
		if (vs!=null) {
			for (int i = 0; i < vs.length; i++) {
				if (vs[0].startsWith(skill.getSkillid())) {
					FrameMessageChangeJpanel.addtext(5,"你已经学会了该技能",null,null);
					return;
				}
			}
		}
		int id =Integer.parseInt(skill.getSkillid());
		int lvl=Integer.parseInt(skill.getSkilllevel());

		StringBuffer buffer=new StringBuffer();
		if (vs!=null) {
			for (int i = 0; i < vs.length; i++) {
				if (buffer.length()!=0) {buffer.append("#");}
				buffer.append(vs[i]);
			}
		}
		if (buffer.length()!=0) {buffer.append("#");}
		buffer.append(id);
		buffer.append("_");
		int sld = AnalysisString.shuliandu(ImageMixDeal.userimg.getRoleShow().getGrade());
		buffer.append(sld);
		data.setSkills("F",buffer.toString());
		SendRoleAndRolesummingUntil.sendRole(data);
		FrameMessageChangeJpanel.addtext(6,"你学会了"+skill.getSkillname(),null,null);
		//ZhuFrame.getZhuJpanel().addPrompt2("你学会了"+skill.getSkillname());
	}

}

